/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package testchat;

import java.io.*;
import java.net.*;

/**
 *
 * @author ThanhKhanh
 */
public class DoCommand implements Runnable
{

    private Socket Socket;
private String line,input;
    public DoCommand()
    {

    }
    public DoCommand(Socket sk)
    {
        Socket = sk;
    }
    public void run()
    {
        try {
            // Get input from the client
            DataInputStream in = new DataInputStream(Socket.getInputStream());
            PrintStream out = new PrintStream(Socket.getOutputStream());

            while ((line = in.readLine()) != null && !line.equals(".")) {
                input = input + line;
                out.println("I got:" + line);

            }

            // Now write to the client

            System.out.println("Overall message is:" + input);
            out.println("Overall message is:" + input);

            Socket.close();
        } catch (IOException ioe) {
            System.out.println("IOException on socket listen: " + ioe);
            ioe.printStackTrace();
        }
    }
   

    /**
     * @return the Socket
     */
    public Socket getSocket() {
        return Socket;
    }

    /**
     * @param Socket the Socket to set
     */
    public void setSocket(Socket Socket) {
        this.Socket = Socket;
    }

}
